#include <QApplication>
#include <QLocale>
#include <QTranslator>
#include <QScreen>
#include <QGuiApplication>
#include <QLoggingCategory>
#include <QStyleFactory>
#include "mainwindow.h"
#include "commWithBridge.h"
#include "logger.h"

int main(int argc, char *argv[])
{
    // 初始化ROS上下文
    // rclcpp::init(argc, argv);

    QApplication a(argc, argv);

    QTranslator translator;
    const QStringList uiLanguages = QLocale::system().uiLanguages();
    for (const QString &locale : uiLanguages) {
        const QString baseName = "ros_gui_app_" + QLocale(locale).name();
        if (translator.load(":/i18n/" + baseName)) {
            a.installTranslator(&translator);
            break;
        }
    }

    // 隐藏鼠标光标
    QGuiApplication::setOverrideCursor(Qt::BlankCursor);

    MainWindow w;
    // 固定显示大小为1280x800
    // w.setFixedSize(1280, 800);
    w.setFixedSize(1920, 1080);
    // w.show();
    w.showFullScreen();
    qInstallMessageHandler(Logger::messageHandler);
    Logger::instance().setOutputTargets(true, true, "gui_app.log");

    commWithBridge commBridge(&w);
    commBridge.commWithBridgeInit();
    commBridge.connToBridge();

    w.commSigProcessInit(&commBridge);

    int result = a.exec();

    return result;
}
